App.controller('resourceDayController', ['$rootScope', '$scope', '$state', 'Page', function ($rootScope, $scope, $state, Page) {


    $scope.reset = function() {
        $scope.query = {};
    };

    $scope.queryData = function() {
        if($scope.query.lineNo != undefined && $scope.query.lineNo != ""
            && $scope.query.startDate != undefined && $scope.query.startDate != ""
            && $scope.query.endDate != undefined && $scope.query.endDate != "") {
            Page.ajaxPost('media/resource/resourceDayQuery.do',$scope.query, function(resp) {
                $scope.total = resp.data.length;
                var showDataList = resp.data;
                if(showDataList.length > 0) {
                    $scope.totalPages = Math.ceil(showDataList.length / 10);
                    if($scope.totalPages > 1) {
                        $scope.showDataList = showDataList.slice(0,10);
                    } else if($scope.totalPages = 1) {
                        $scope.showDataList = showDataList;
                    } else {
                        $scope.showDataList = [];
                    }
                    laypage({
                        cont : 'page_bar',
                        pages : $scope.totalPages,// 得到总页数
                        skin : '#3E97E4',
                        skip : true, // 是否开启跳页
                        prev : '<', // 若不显示，设置false即可
                        next : '>', // 若不显示，设置false即可
                        groups : 10, //连续分页数
                        last : $scope.totalPages,
                        curr: 1, //初始化当前页
                        jump : function(obj,first) {// 触发分页后的回调
                            /*obj是一个object类型。包括了分页的所有配置信息。
                             first一个Boolean类，检测页面是否初始加载。非常有用，可避免无限刷新。*/
                            if(!first){
                                //var param = {};
                                Page.ajaxPost('media/resource/resourceDayQuery.do', $scope.query,function(resp){
                                    $scope.showDataList = resp.data.slice((obj.curr - 1) * 10, obj.curr * 10);
                                });
                            }
                        }
                    })
                } else {
                    Page.notice("未找到数据!");
                    return;
                }
            })
        } else {
            Page.notice("请填写线路、运行起止时间!");
            return;
        }



    };


}]);
